<style>
.bdr, .col {
    border-left: 1px solid #fff;
    border-right: 1px solid #ccc;
}
.bdrBottom {
    border-bottom: 1px solid #ccc;
}
.col {
    width: 70px;
    padding: 3px 5px;
}
input.input {
    width: 50px;
    font-size: 11px;
    font-family: Lucida Grande,Verdana,Arial,Bitstream Vera Sans,sans-serif;
    text-align: right;
    width: 42px;
    padding: 2px 3px;
}
div.saving {
    color: #FF8000;
    font-style: italic;
}
thead td.col {
    background-color: #EAEAEA;
}
#stocks tbody tr:hover {
    background-color: #D9EBF5;
}
</style>

<div class="wrap" style="padding-top:8px;">
  <div id="icon-index" class="icon32"></div>
  <div class="wrap fLeft"><h2 style="padding-top:0;"><?php e($pageTitle) ?></h2></div>
  <div id="message"></div>
  <div id="progress" class="fRight" style="visibility:hidden;"></div>
  <div class="clear"></div>

  <div id="grid-wrap">
    <form id="form-stock" method="post" action="<?php e($this->base); ?>/admin/<?php e($this->params['controller']); ?>/update" onsubmit="return save();">

    <table cellpadding="6" cellspacing="0" border="0" align="center" style="margin-top:10px; border:1px solid #ccc;">
      <thead>
        <tr>
          <td colspan="5" class="col bdrBottom" style="height:30px;">
            <b>Stockist: <?php e($stockist); ?></b>
            <input type="hidden" name="stockist_id" value="<?php e($stockist_id); ?>" />
          </td>
        </tr>
      </thead>
      <tr>
        <td>Category:</td>
        <td>
          <select name="type" class="select req">
            <option value="">select..</option>
            <option value="PA">Purchase</option>
            <option value="PR">Purchase Return</option>
            <option value="TR">Transfer In</option>
            <option value="TO">Transfer Out</option>
            <option value="SA">Sales</option>
            <option value="SR">Sales Return</option>
            <option value="DA">Damage</option>
            <option value="LO">Loss</option>
            <option value="PM">Promotion</option>
            <option value="AS">Other Adjustment</option>
          </select>
        </td>
        <td width="30">&nbsp;</td>
        <td>Date:</td>
        <td style="padding-right:8px;">
          <input type="hidden" id="date" name="date" />
          <input type="text" id="show-date" value="select.." readonly="readonly" class="date req" />
          <input type="text" id="time" name="time" value="<?php echo date('g:i A'); ?>" class="time req" style="width:48px;" />
        </td>
      </tr>
      <tr>
        <td valign="top" style="padding-top:8px;">Remark:</td>
        <td colspan="4" style="padding-right:8px;"><textarea name="remark" class="input" style="width:460px;"></textarea></td>
      </tr>
      <tr>
        <td colspan="5" align="center">
          <input type="submit" id="submit" value="Save" />
          <input type="reset" value="Reset" />
        </td>
      </tr>
    </table>
    <table id="stocks" cellpadding="5" cellspacing="0" border="0" style="margin-top:10px; border:1px solid #ccc;">
      <thead>
        <tr>
          <td height="30" class="col bdrBottom">#</td>
          <td class="col bdrBottom"><?php __('Product Id'); ?></td>
          <td class="col bdrBottom" style="width:380px;"><?php __('Product Name'); ?></td>
          <td class="col bdrBottom"><?php __('Price'); ?></td>
          <td class="col bdrBottom" style="width:95px;"><?php __('Current Balance'); ?></td>
          <td class="col bdrBottom" style="width:78px;"><?php __('Quality'); ?> (+/-)</td>
        </tr>
      </thead>
      <tbody>
<?php $i = 0;
      foreach ($data as $i=>$stock) {
        $id    = $stock['p']['id'];
        $style = ($i%2==0)?'':' style="background-color: #E3E3E3;"';
        $i++; ?>
        <tr>
          <td class="col"<?php e($style); ?>><?php e($i); ?></td>
          <td class="col"><div><?php e($stock['p']['code']); ?></div></td>
          <td class="col"><div><?php e($stock['p']['name']); ?></div></td>
          <td class="col right"><div><?php e($stock['p']['price']); ?></div></td>
          <td class="col right"><div id="cp_<?php e($id); ?>"><?php e($stock['s']['balance']); ?></div></td>
          <td class="col center">
            <input type="text" id="p_<?php e($id); ?>" name="p_<?php e($id); ?>" value="0" class="qty" autocomplete="off" style="width:50px; text-align:right;" />
          </td>
        </tr>
<?php } ?>
      </tbody>
    </table>
    </form>
  </div>
</div>
<script>
<?php $this->addScript('Ext.onReady(function() { init(); });'); ?>
</script>